<?php
	session_start();
	require("../config.php");
  	require_once($CONF['root.dir']."database.php");
	require_once($CONF['root.dir']."Modules/tabelClass.php");
	
	$kolomCari=$_GET["kolomCari"];
	$tipeCari=$_GET["tipeCari"];
	$dataCari=$_GET["dataCari"];
	
	if ($_GET['i'] == ""){
		$index = 1;
	}else{
		$index = $_GET['i'];
	}

	if ($_GET["aksi"] == "hapusData"){
		$idHapus = $_GET["idHapus"];
		$idArray = explode(";",$idHapus);
		for ($counter=0;$counter<(count($idArray)-1);$counter++){
			$SQL = "DELETE FROM tbllamaran WHERE id_pelamar = '".$idArray[$counter]."'";
			$conn->connect();
			$exec = $conn->execute($SQL);
			$conn->disconnect();
		}		
	}
	
	$tabelClass = new tabelClass();
	$tabelClass->connection = $conn;
	$tabelClass->widthno='3%';
	
	$arrayHeader = array("ID Pelamar","Nama","Tempat/Tgl Lahir","Alamat","Telepon","Jns.Kelamin","Status","Pendidikan","IPK");
	$arrayAlign = array("","","","","","center","center","","center");
	$arrayWidth = array("8%","15%","13%","15%","8%","10%","8%","10%","8%");

	$SQL="SELECT id_pelamar, nama,CONCAT(tmp_lahir,', ',DATE_FORMAT(tgl_lahir,'%d-%m-%Y'))lahir,alamat,telepon,if(jns_kelamin='L','Pria','Wanita'),STATUS,
		  CONCAT(pendidikan,',',jurusan) pendidikan,ipk,id_pelamar id FROM tbllamaran";
	
	if($kolomCari!=""){
		$SQL.=" WHERE ".$kolomCari." LIKE '%".trim(strtoupper($dataCari))."%'";
	}
	
	$tabelClass->sql = $SQL;
	$tabelClass->index = $index;
	$tabelClass->dataPerPage = 10;
	$tabelClass->aksiAjax = "Modules/getLamar2.php?";
	$tabelClass->FormName = "FrmTbllamar";
	$tabelClass->divAjax = "divlamar";
	$tabelClass->showChkPanel = true;
	$tabelClass->indexEdit = "0";
	$tabelClass->showIcon = true;

	//$arrayIcon[] = array("1","", "ui-icon-newwin", "New", "ShowPopUp('SubModules/getFrmLamar.php','',550,480)", "1");
	$arrayIcon[] = array("1","", "ui-icon-wrench", "Edit", "Edit('SubModules/getFrmLamar.php','FrmTbllamar','divlamar',550,480)", "1");
	$arrayIcon[] = array("1","", "ui-icon-trash", "Hapus", "Delete('Modules/getLamar2.php?','FrmTbllamar','divlamar')", "1");
	
	$tabelClass->arrayIcon = $arrayIcon;
	$tabelClass->field = $arrayHeader;
	$tabelClass->alignKolom = $arrayAlign;
	$tabelClass->widthKolom = $arrayWidth;
	$tabelClass->border = "0";
	$tabelClass->cellpadding = "1";
	$tabelClass->width = "100%";	
	$content .= $tabelClass->drawTabel();
	echo $content;

?>
